Skip to content

fix(container): install libyaml-dev so bundle install can compile psych (#28) - #29

Merged
matthew-on-git merged 1 commit into
mainfrom
fix/libyaml-dev-for-bundle-install
Apr 29, 2026
Merged

fix(container): install libyaml-dev so bundle install can compile psych (#28)#29
matthew-on-git merged 1 commit into
mainfrom
fix/libyaml-dev-for-bundle-install

Conversation

@matthew-on-git

Copy link
Copy Markdown
Contributor

Summary

Follow-up to v1.9.0 (issue #25). Closes #28.

v1.9.0 shipped `libyaml-0-2` (runtime lib only) which is enough for the in-container rubocop/reek/etc. to start. But a Rails 7+ project that runs `bundle install` against its own Gemfile fails because compiling `psych` 5.x natively needs libyaml's headers. The resolution chain is:

```
debug -> irb -> rdoc -> psych (psych native compile fails: missing yaml.h)
```

Rails 7.1+ projects ship `gem 'debug'` in the dev/test group by default, so this hits everyone.

Change

Single Dockerfile swap: `libyaml-0-2` → `libyaml-dev`. `libyaml-dev` depends on `libyaml-0-2` transitively so the runtime lib is still present; no other change needed in the Ruby builder stage or COPY layout.

Smoke-test extension

`tests/smoke-rails.sh` already creates a Rails-shaped fixture with the right Gemfile (was added in PR #26 for issue #25). Added a third assertion to it:

  1. ✅ Gemfile with `platforms: %i[mri windows]` parses (existing — issue Ruby support is not consumable by Rails projects out-of-the-box (image vintage + reek/rubocop scope) #25)
  2. ✅ `make _lint` scopes to RUBY_PATHS (existing — issue Ruby support is not consumable by Rails projects out-of-the-box (image vintage + reek/rubocop scope) #25)
  3. `bundle install` succeeds, `require 'psych'` works inside the bundle (new — issue Container missing libyaml-dev — bundle install fails on psych for Rails projects with the debug gem #28)

End-to-end runtime: ~36s against a freshly built image.

Also fixed the smoke test's cleanup trap — `bundle install` writes root-owned files into the bind-mounted fixture, and the host-side `rm -rf` couldn't delete them. Cleanup now runs inside a docker container.

Acceptance criteria from issue #28

  • Container image installs `libyaml-dev`
  • `bundle install` succeeds for the Rails-shaped fixture (Gemfile contains `gem 'debug'`)
  • CI smoke test exercises the path
  • CHANGELOG entry under "Fixed"

Test plan

  • Image rebuilds cleanly (cached layers; ~2m incremental, ~5m full)
  • `tests/smoke-rails.sh` passes end-to-end against the freshly built image
  • `make _check` on dev-toolchain itself passes
  • CI green on this PR (build/scan/sign + smoke-rails job)

Recommended next step

Cut a `v1.9.1` patch release once merged (`make release VERSION=1.9.1`). Pure bugfix, patch-bump appropriate.

🤖 Generated with Claude Code

…ch (#28)

Follow-up to v1.9.0 (issue #25). v1.9.0 shipped libyaml-0-2 (runtime lib only)
which lets the in-container rubocop/reek/etc. start, but a Rails 7+ project
running `bundle install` against its own Gemfile fails because compiling
psych 5.x natively needs libyaml's headers. Resolution chain:

  debug -> irb -> rdoc -> psych  (psych compile fails: missing yaml.h)

Replace libyaml-0-2 with libyaml-dev in the runtime apt block. libyaml-dev
depends on libyaml-0-2 transitively, so the runtime lib is still present;
no other change needed in the Ruby builder stage or COPY layout.

Also extend tests/smoke-rails.sh with a third assertion: run `bundle install`
against the Rails-shaped fixture's Gemfile (which contains `gem 'debug'`)
and require 'psych' inside the resulting bundle. The existing fixture already
included the right Gemfile shape — only the install step is new.

Cleanup: bundle install writes root-owned files into the bind-mounted
fixture; the existing host-side `rm -rf` couldn't delete them. Moved the
cleanup into a docker run so it executes as root inside the container.

Tested:
- smoke-rails.sh: all three checks pass (Gemfile parse, lint scope,
  bundle install + psych load) in ~36s end-to-end against a freshly built image
- make _check on dev-toolchain itself: pass

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@matthew-on-git
matthew-on-git merged commit c588028 into main Apr 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Container missing libyaml-dev — bundle install fails on psych for Rails projects with the debug gem

1 participant